import http from './interface'

/**
 * 将业务所有接口统一起来便于维护
 * 如果项目很大可以将 url 独立成文件，接口分成不同的模块
 * 
 */

// 单独导出(测试接口) import {test} from '@/common/vmeitime-http/'
export const test = (data) => {
	/* http.config.baseUrl = "http://localhost:8080/api/"
	//设置请求前拦截器
	http.interceptor.request = (config) => {
		config.header = {
			"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
		}
	} */
	//设置请求结束后拦截器
	http.interceptor.response = (response) => {
		console.log('个性化response....')
		//判断返回状态 执行相应操作
		return response;
	}
	return http.request({
		baseUrl: 'https://unidemo.dcloud.net.cn/',
		url: 'ajax/echo/text?name=uni-app',
		dataType: 'text',
		data,
	})
}

// 轮播图
export const banner = (data) => {
	return http.request({
		url: '/banner/36kr',
		method: 'GET',
		data,
		// handle:true
	})
}

// 登录
export const pcLogin = (data) => {
	return http.request({
		url: '/login/pcLogin',
		method: 'POST',
		data,
		// handle:true
	})
}

// 获取账号详细信息
export const getXntAccountList = (data) => {
	return http.request({
		url: '/xntAdmin/getXntAccountOrMessList',
		method: 'POST',
		data,
		// handle:true
	})
}

// 获取全部分类（代参获取个别）
export const selectGoodType = (data) => {
	return http.request({
		url: '/xntGoodType/selectGoodType',
		method: 'POST',
		data,
		// handle:true
	})
}

// 获取商品信息 typeId
export const getCommoditys = (data) => {
	return http.request({
		url: '/xntCommodity/getCommoditys',
		method: 'POST',
		data,
		// handle:true
	})
}

// 查询订单
export const selectOrder = (data) => {
	return http.request({
		url: '/xntOrder/selectOrder2',
		method: 'POST',
		data,
		// handle:true
	})
}

// 查询订单明细？（订单表以及订单明细表）
export const selectOrderOrItem = (data) => {
	return http.request({
		url: '/xntOrder/selectOrderOrItem',
		method: 'POST',
		data,
		// handle:true
	})
}

// 获取账号详细信息
export const getXntAccountOrMessList = (data) => {
	return http.request({
		url: '/xntAdmin/getXntAccountOrMessList',
		method: 'POST',
		data,
		// handle:true
	})
}

// 添加商品
export const addCommodity = (data) => {
	return http.request({
		url: '/xntCommodity/addCommodity',
		method: 'POST',
		data,
		// handle:true
	})
}

// 账号注册 0厂家/1经销商/2农户/3批发商
export const addXntAccount = (data) => {
	return http.request({
		url: '/xntAccount/addXntAccount',
		method: 'POST',
		data,
		// handle:true
	})
}

// 设置账号详细信息
export const setXntAccountOrMessList = (data) => {
	return http.request({
		url: '/xntAdmin/setXntAccountOrMessList',
		method: 'POST',
		data,
		// handle:true
	})
}

// 获取厂商信息，商城
export const getXntmanufactorList = (data) => {
	return http.request({
		url: '/xntAdmin/getXntmanufactorList',
		method: 'POST',
		data,
		// handle:true
	})
}

// 确认收货
export const confirmOrder = (data) => {
	return http.request({
		url: '/xntOrder/confirmOrder',
		method: 'POST',
		data,
		// handle:true
	})
}

// 添加商品生成订单
export const orderPayOrder = (data) => {
	console.log(data)
	return http.request({
		baseUrl: 'http://xnt.longshunha.com:88/xnt',
		//baseUrl: 'http://192.168.0.3:8080/xnt',
		url: '/order/payOrder',
		method: 'POST',
		data,
		// handle:true
	})
}

// 更新商品信息 下架
export const setCommodity = (data) => {
	return http.request({
		url: '/xntCommodity/setCommodity',
		method: 'POST',
		data,
		// handle:true
	})
}

// 添加商品库存 减少商品库存
export const addCommodityInventory = (data) => {
	return http.request({
		url: '/xntCommodity/addCommodityInventory',
		method: 'POST',
		data,
		// handle:true
	})
}

// 默认全部导出  import api from '@/common/vmeitime-http/'
export default {
	test,
	banner,
	getXntAccountList,
	pcLogin,
	selectGoodType,
	getCommoditys,
	selectOrder,
	selectOrderOrItem,
	getXntAccountOrMessList,
	addCommodity,
	addXntAccount,
	setXntAccountOrMessList,
	getXntmanufactorList,
	orderPayOrder,
	confirmOrder,
	setCommodity,
	addCommodityInventory,
}
